<head>
    <script language="JavaScript" type="text/javascript">
	<!--
	function switchTable(id) {
	    if (document.getElementById('table' + id).style.display == 'none') {document.getElementById('table' + id).style.display = '';} 
	    else {document.getElementById('table' + id).style.display = 'none';}
	}
	//-->
    </script>       
</head>

<h2> Bericht Kind</h2>
<div id="child">
    <table>
	<caption> Kind </caption>
	<thead>
	    <tr>
		<th>Vorname</th>
		<th>Nachname</th>
		<th>Alter</th>
		<th>Geschlecht</th>
		<th>Ranking-Punkte</th>
		<th>Info</th>
		<th>Ändern</th>
	    </tr>
	</thead>
	<tbody>
	    <tr>
		<td><?php echo $this->children['forename'] ?></td>
		<td><?php echo $this->children['surname'] ?></td>
		<td><?php echo $this->children['age'] ?></td>
		<td><?php echo $this->children['gender'] ?></td>
		<td><?php echo $this->children['ranking_points'] ?></td>
		<td><a href="/child/info/id/<?php echo $this->children['id'] ?>/from/<?php echo $from = 2 ?>">info</a></td>
		<td><a href="/child/update/id/<?php echo $this->children['id'] ?>/from/<?php echo $from = 2 ?>">ändern</a></td>

	    </tr>
	</tbody>
    </table>
</div>

<p></p>

<div id="parent">
    <?php if (isset($this->parents) && count($this->parents) > 0) : ?>
        <table>
    	<caption> Eltern </caption>
    	<thead>
    	    <tr>
    		<th>Vorname</th>
    		<th>Nachname</th>
    		<th>Telefonnummer</th>
    		<th>Mobile-Nummer</th>
    		<th>Verknüpfung</th>
    		<th>Info</th>
    		<th>Ändern</th>
    	    </tr>
    	</thead>
    	<tbody>
		<?php foreach ($this->parents as $parent) : ?>
		    <tr>
			<td><?php echo $parent['forename'] ?></td>
			<td><?php echo $parent['surname'] ?></td>
			<td><?php echo $parent['telnumber'] ?></td>
			<td><?php echo $parent['mobilenumber'] ?></td>
			<td><a class="confirm" id="<?= $allocate['id'] ?>" name="<?php echo $parent['forename'] . " " . $parent['surname'] ?> und <?php echo $this->children['forename'] . " " . $this->children['surname'] ?>" href="/allocate/allocatedelete/id/<?php echo $this->children['id'] ?>/plp_id/<?php echo $parent['plp_id'] ?>/from/<?php echo $from = 2 ?>">Löschen</a></td>
			<td><a href="/parent/info/id/<?php echo $parent['id'] ?>/child_id/<?php echo $this->children['id'] ?>/from/<?php echo $from = 2 ?>">info</a></td>
			<td><a href="/parent/update/id/<?php echo $parent['id'] ?>/child_id/<?php echo $this->children['id'] ?>/from/<?php echo $from = 2 ?>">ändern</a></td>
			
		    <?php endforeach; ?>
    	</tbody>
	<?php else: ?>
    	<p>Es sind keine Eltern mit <b><?php echo $this->children['forename'] . " " . $this->children['surname'] ?></b> verknüpft</p>
	<?php endif ?>
    </table>
    <?php if (count($this->parents) < 2): ?>
        <p>Um ein Elternteil zu suchen, klicken Sie bitte auf <a href="/allocate/allocate/id/<?php echo $this->children['id'] ?>/from/<?php echo $from = 2 ?>">"Eltern suchen"</a></p>
        <p>Um ein Elternteil erstellen, klicken Sie bitte auf <a href="/parent/create/from/<?php echo $from = 2 ?>/child_id/<?php echo $this->children['id'] ?>">"Neues Elternteil erstellen"</a></p>
    <?php endif ?>
</div>

<p></p>

<div id="events">
    <?php if (count($this->events) > 0): ?>   
        <table>

    	<caption> Termine</caption>
    	<thead>
    	    <tr>
    		<th>Datum</th>
      		<th>Wochentag</th>
    		<th>Uhrzeit</th>
    		<th>Rhythmus</th>
    		<th>Termin Typ</th>
    		<th>Status</th>
    		<th>Ändern</th>
    	    </tr>
    	</thead>
	    <?php foreach ($this->events as $event) : ?>
		<?php
		$weekday = array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "SSonntag");
		$day = strtotime($event['date_from']);

		$start_date = date("d-m-Y", strtotime($event['date_from']));
		$end_date = date("d-m-Y", strtotime($event['date_to']));
		$start_time = date("H:i", strtotime($event['date_from']));
		$end_time = date("H:i", strtotime($event['date_to']));

		if ($event['idevent_series'] > 0)
		{
		    $rythmus = "Wöchentlich";
		} else
		{
		    $rythmus = "Einmalig ";
		};
		?>
		<tr>
		    <td><?php echo $start_date ?></td>
		    <td><?php echo $weekday[date("w", $day)] ?></td>
		    <td><?php echo $start_time ?> bis <?php echo $end_time ?></td>
		    <td><?php echo $rythmus ?></td>
		    <td><?php echo $event['event_type'] ?></td>
		    <td><?php echo $event['event_status'] ?></td>
		    <td><a href="/child/forward?url=/event/update/id/<?php echo $event['id'] ?>&from=/child/report/id/<?php echo $this->children['id'] ?>">Ändern</a></td>
		</tr>
	    <?php endforeach; ?>
	<?php else: ?>
    	<p>Es sind keine Termine für <b><?php echo $this->children['forename'] . " " . $this->children['surname'] ?></b> vorhanden</p>
	<?php endif ?>   
    </table>
   <td><p>Um einen neuen Termin zu erstellen, klicken Sie bitte auf <a href="/child/forward?url=/request/prepare/child_id/<?php echo $this->children['id'] ?>&from=/child/report/id/<?php echo $this->children['id'] ?>">Termin erstellen</a></td>
    
</div>
<p></p>

<div id="eventsold">
    <?php if (count($this->eventsold) > 0): ?>   
        <p>Termine in der Vergangenheit  <a href="javascript:switchTable(4)">Anzeigen lassen</a><p>
        <table id="table4" style="display: none">
    	<caption> Alte Termine</caption>
    	<thead>
    	    <tr>
    		<th>Datum</th>
    		<th>Wochentag</th>
    		<th>Uhrzeit</th>
    		<th>Rhythmus</th>
    		<th>Termin Typ</th>
    		<th>Status</th>
    		<th>Ändern</th>
    	    </tr>
    	</thead>
	    <?php foreach ($this->eventsold as $event) : ?>
		<?php
		$weekday = array("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "SSonntag");
		$day = strtotime($event['date_from']);

		$start_date = date("d-m-Y", strtotime($event['date_from']));
		$end_date = date("d-m-Y", strtotime($event['date_to']));
		$start_time = date("H:i", strtotime($event['date_from']));
		$end_time = date("H:i", strtotime($event['date_to']));

		if ($event['idevent_series'] > 0)
		{
		    $rythmus = "Wöchentlich";
		} else
		{
		    $rythmus = " ";
		};
		?>
		<tr>
		    <td><?php echo $start_date ?></td>
		    <td><?php echo $weekday[date("w", $day)] ?></td>
		    <td><?php echo $start_time ?> bis <?php echo $end_time ?></td>
		    <td><?php echo $rythmus ?></td>
		    <td><?php echo $event['event_type'] ?></td>
		    <td><?php echo $event['event_status'] ?></td>
		    <td><a href="/child/forward?url=/event/update/id/<?php echo $event['id'] ?>&from=/child/report/id/<?php echo $this->children['id'] ?>">Ändern</a></td>
		</tr>
	    <?php endforeach; ?>
        </table>
    <?php endif ?> 
</div>